cmake_minimum_required(VERSION 3.8)

project(websocket-iocp)

set(CMAKE_CXX_STANDARD 17)

# set warning level to max
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
    string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()

find_package(OpenSSL REQUIRED) 
if(OpenSSL_FOUND)
    include_directories(${OPENSSL_INCLUDE_DIRS})
    link_directories(${OPENSSL_LIBRARIES})
    message(STATUS "Using OpenSSL ${OPENSSL_VERSION}")
else()
    message("Cannot find OPENSSL library")
endif()

include_directories("./include")
include_directories("./extern/include") 

aux_source_directory("./include" includes)

add_library(server "./src/server/server.cpp" "./src/websocket.cpp" "./src/server/websocket_server.cpp" ${includes})
add_library(client "./src/client/client.cpp" "./src/websocket.cpp" "./src/client/websocket_client.cpp" ${includes})

add_executable(server_main "./src/server/server_main.cpp" ${includes})
add_executable(client_main "./src/client/client_main.cpp" ${includes})

target_link_libraries(server wsock32 ws2_32)
target_link_libraries(server_main server)
target_link_libraries(client wsock32 ws2_32 OpenSSL::SSL)
target_link_libraries(client_main client)
